From 59d0e58be87d8cb2680b561695e53f672253c16c Mon Sep 17 00:00:00 2001 From: "lcy@vtsmp-build.sh.intel.com" Date: Sun, 28 Aug 2005 14:55:37 +0800 Subject: [PATCH] Update __vmread() To make it not to break the stack. Signed-off-by: Jun Nakajima Signed-off-by: Chengyuan Li --- xen/include/asm-x86/vmx.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-x86/vmx.h b/xen/include/asm-x86/vmx.h index 0d40e51068..1d9b74dfb5 100644 --- a/xen/include/asm-x86/vmx.h +++ b/xen/include/asm-x86/vmx.h @@ -275,7 +275,9 @@ static inline int __vmpclear (u64 addr) return 0; } -static inline int __vmread (unsigned long field, void *value) +#define __vmread(x, ptr) ___vmread((x), (ptr), sizeof(*(ptr))) + +static always_inline int ___vmread (const unsigned long field, void *ptr, const int size) { unsigned long eflags; unsigned long ecx = 0; @@ -286,7 +288,23 @@ static inline int __vmread (unsigned long field, void *value) : "a" (field) : "memory"); - *((long *) value) = ecx; + switch (size) { + case 1: + *((u8 *) (ptr)) = ecx; + break; + case 2: + *((u16 *) (ptr)) = ecx; + break; + case 4: + *((u32 *) (ptr)) = ecx; + break; + case 8: + *((u64 *) (ptr)) = ecx; + break; + default: + domain_crash_synchronous(); + break; + } __save_flags(eflags); if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF) -- 2.30.2